package com.it.sun.esaychat.chat.controller;


import com.it.sun.easychat.common.context.Current;
import com.it.sun.easychat.model.util.ResultHelper;
import com.it.sun.easychat.model.vo.ResultVO;
import com.it.sun.esaychat.chat.entity.MessageEntity;
import com.it.sun.esaychat.chat.service.IMessageServices;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author sunmannian
 * @since 2020-05-27
 */
@RestController
@RequestMapping("/message/entity")
@Api(tags = "消息对象服务类")
public class MessageController {

    @Autowired
    private IMessageServices messageServices;


    @PostMapping()
    @ApiOperation("新增一条消息")
    public ResultVO<Void> save(@RequestBody MessageEntity messageEntity) {
        messageServices.save(messageEntity);
        return ResultHelper.success();
    }

    @GetMapping()
    public ResultVO<List<MessageEntity>> list() {
        return ResultHelper.getSuccess(messageServices.list());
    }


}

